// 文件名：知识树/编程语言/Java/ast/EmployeeService.java
package com.example;

import java.util.List;
import java.util.ArrayList;
import java.io.Serializable;

public class EmployeeService extends BaseService implements Serializable {
    private static final Logger logger = Logger.getLogger(EmployeeService.class.getName());

    public EmployeeService(EmployeeDao employeeDao) {
        super.init(employeeDao);
    }

    public List<Employee> getActiveEmployees(String department, double minSalary) throws SQLException {
        List<Employee> result = new ArrayList<>();

        try (Connection conn = dataSource.getConnection()) {
            PreparedStatement stmt = conn.prepareStatement("SELECT * FROM employees WHERE active = ?");
            stmt.setBoolean(1, true);

            for (ResultSet rs = stmt.executeQuery(); rs.next(); ) {
                result.add(EmployeeMapper.mapRow(rs));
            }
        } catch (SQLException e) {
            logger.error("Database error", e);
            throw e;
        } finally {
            DBUtil.closeQuietly(stmt, conn);
        }

        return result;
    }
}
